/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package interceptor;

import BUSServices.LoaiSach;
import BUSServices.QLNSBUSWebService;
import BUSServices.QLNSBUSWebService_Service;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
import java.util.List;
import org.apache.struts2.dispatcher.RequestMap;

/**
 *
 * @author USER
 */
public class HeaderMenu implements Interceptor {

    QLNSBUSWebService_Service service;
    QLNSBUSWebService port;
    private List<LoaiSach> listLoaiSach;

    public List<LoaiSach> getListLoaiSach() {
        return listLoaiSach;
    }

    @Override
    public void destroy() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void init() {
        service = new QLNSBUSWebService_Service();
        port = service.getQLNSBUSWebServicePort();
    }

    @Override
    public String intercept(ActionInvocation ai) throws Exception {
        RequestMap map = (RequestMap) ai.getInvocationContext().get("request");
        listLoaiSach = port.layDanhSachLoaiSach();
        map.put("listLoaiSach", listLoaiSach);
        return ai.invoke();
    }
}
